<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增项目计划')"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-plan-add">
        <input name="trainPackageId" id="trainPackageId" th:value="${trainPackageId}" type="hidden"/>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">题库名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="subjectName" id="subjectName" required>
            </div>
        </div>
        <div class="form-group">
            <div id="menuTrees" class="ztree ztree-border"></div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: ztree-js"/>
<script type="text/javascript">
    // 字典
    var prefix = ctx + "business/trainPackageProject";
    $(function () {
        var url = prefix + "/getProjectTree?trainPackageProjectId=";
        var options = {
            id: "menuTrees",
            url: url,
            check: {enable: true, chkboxType: {"Y": "", "N": ""}},
            expandLevel: 0
        };
        $.tree.init(options);

    });


    function submitHandler() {
        add();
    }

    function add() {
        var menuIds = $.tree.getCheckedNodes();
        $.ajax({
            cache: true,
            type: "POST",
            url: prefix + "/add",
            data: {
                "subjectName": $("#subjectName").val(),
                "trainPackageId": $("#trainPackageId").val(),
                "integrationIds": menuIds
            },
            async: false,
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.successCallback(data);
            }
        });
    }
</script>
</body>
</html>
